import { Component, Input, OnInit } from '@angular/core';
import { GifserviceService } from  '../gifservice.service';
import { Gif } from '../gif';


@Component({
  selector: 'app-giflist',
  templateUrl: './giflist.component.html',
  styleUrls: ['./giflist.component.css'],
  providers:[GifserviceService]
})
export class GiflistComponent implements OnInit {
  private gifs: Gif[];
  private page: number;

  constructor(
    private gifService: GifserviceService
  ) {
    this.page = 0;
  }

  ngOnInit() {
    this.gifService.getGifList(this.page)
      .then(data => {
        this.gifs = data;
      });
  }

  loadMore() {
    this.page ++;
    //this.gifs = this.gifService.getGifList(this.page);
    this.gifService.getGifList(this.page)
      .then(data => {
        this.gifs = data;
      });
  }


}
